﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using thinger.AutomaticStoreMotionDAL;
using thinger.AutomaticStoreMotionModels;

namespace thinger.AutomaticStoreMotionPro
{
    internal static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Mutex mutex = new Mutex(true, "OnlyStartOnce", out bool createNew);
            if (createNew)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                //设置数据库连接字符串
                SqlSugarService.SetConnectionString("Data Source=" + Application.StartupPath + "\\DataBase\\AutomaticStoreMotion;Pooling=true;FailIfMissing=false ");
                Form frmLogin = new FrmLogin();
                frmLogin.TopMost = true;
                frmLogin.ShowDialog();
                if (frmLogin.DialogResult == DialogResult.OK)
                {
                    Application.Run(new FrmMain());
                }
                else
                {
                    Application.Exit();
                }
            }
            else
            {
                MessageBox.Show("程序重复打开，只允许运行一次");
            }

        }

        //全局用户变量
        public static SysAdmin mySysAdmin;

    }
}
